<?php

class Place_IndexController extends Zend_Controller_Action
{
    public function indexAction()
    {
        $this->view->title = 'Welcome to Places to take the kids!';
        $this->view->headTitle('Welcome');
        $placesFinder = new Places();
        $this->view->places = $placesFinder->fetchLatest();
    }

    public function menuAction()
    {
        // example of how to prevent direct access to this action
        $request = $this->getRequest();
        if($request->getParam('module') == $request->getModuleName()
            && $request->getParam('controller') == $request->getControllerName()
            && $request->getParam('action') == $request->getActionName()) {
            // direct call to an actionStack-only action.
            $this->_helper->redirector->gotoRouteAndExit(array(), null, true);
        }
        // end example
        
        $mainMenu = array(
            array('title'=>'Home', 'url'=>$this->view->url(array(), null, true)),
            array('title'=>'Browse Places', 'url'=>$this->view->url(array('controller'=>'place', 'action'=>'browse'), null, true)),
            array('title'=>'Articles', 'url'=>$this->view->url(array('controller'=>'articles'), null, true)),
            array('title'=>'About', 'url'=>$this->view->url(array('controller'=>'about'), null, true)),
        );

        $this->view->menu = $mainMenu;
        $this->_helper->viewRenderer->setResponseSegment('menu');
    }
    
    public function advertAction()
    {
        $this->_helper->viewRenderer->setResponseSegment('advert');
    }
}
